/*
 * @Author: nns4
 * @Date: 2019-10-31 17:37:55
 * @LastEditors  : nns4
 * @LastEditTime : 2020-01-22 12:36:04
 * @FilePath: /wxShop/src/store/module/app.js
 * @Description: 
 */
export default {
    state: {
        activeNav: "home", //当前页面
        hideNavs: [], //隐藏底部导航的页面
        hideBackTops: [], //隐藏返回顶部的页面
        pageCache: [], //缓存的页面
        pageCacheScroll: {
            //缓存页面的滚动条位置

        }
    },
    mutations: {
        setHideNavs(state, data) {
            return state.hideNavs = data
        },
        setHideBackTops(state, data) {
            return state.hideBackTops = data
        },
        setActiveNav(state, data) {
            return state.activeNav = data
        },
        setPageCache(state, data) {
            return state.pageCache = data
        },
        setPageCacheScroll(state, data) {
            let obj = {}
          
            data.map(v => {
                obj[v] = 0
            })
            return state.pageCacheScroll = obj
        },
        setPageCacheScrollItem(state, data) { 
            return state.pageCacheScroll[data.name]=data.scroll

        }
    },
    getters: {
        getHideNavs(state) {
            return state.hideNavs
        },
        getHideBackTops(state) {
            return state.hideBackTops
        },
        getActiveNav(state) {
            return state.activeNav
        },
        getPageCache(state) {
            return state.pageCache
        }

    },
    actions: {
        APageCache: ({
            commit,
            state
        }, data) => {
            commit("setPageCache", data);
            commit("setPageCacheScroll", data);
        }
    }
}